<template>
  <div id="swiper">
    <swiper :options="swiperOption" v-if="showSwiper">
    <swiper-slide v-for="slide in swiperList" :key="slide.id">
      <img :src="slide.imgUrl" alt="">
    </swiper-slide>
    <div class="swiper-pagination change" slot="pagination"></div>
  </swiper>
  </div>
</template>

<script>
export default {
  name: 'carrousel',
  props: {
    swiperList: {
      type: Array,
      default () {
        return []
      }
    }
  },
  data () {
    return {
      swiperOption: {
        pagination: {
          el: '.swiper-pagination'
        },
        loop: true
      }
    }
  },
  computed: {
    showSwiper () {
      return this.swiperList.length
    }
  }
}
</script>

<style lang='less' scoped>
.change /deep/ .swiper-pagination-bullet {
  width: 0.1rem;
  height: 0.1rem;
}
.change /deep/ .swiper-pagination-bullet-active {
  width: 0.2rem;
  height: 0.1rem;
  border-radius: 30%;
  background-color: #fff;
}
#swiper {
  width: 100%;
  height: 0;
  padding-bottom:31.25% ;
  overflow: hidden;
  background-color: #eee;
  img{
    width: 100%;
  }
}
</style>
